home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / graphics / flick_12.zip / FORMAT < prev    next >
Text File  |  1991-03-15  |  7KB  |  177 lines

  1. Newsgroups: comp.graphics
  2. Subject: Re: FLI file-format?
  3. Message-ID: <1991Mar12.202026.5005@ncsu.edu>
  4. From: kdarling@hobbes.ncsu.edu (Kevin Darling)
  5. Date: 12 Mar 91 20:20:26 GMT
  6. References: <172@gem.stack.urc.tue.nl>
  7. Organization: North Carolina State University
  8. Keywords: FLI, file-format
  9.  
  10. >Has someone a description of the FLI-format?
  11.  
  12. Autodesk Animator files explanation (.FLI only excerpted).  I believe
  13. that the original programmer wrote up this doc.  It's correct, as I've
  14. used the info to realtime playback stock .FLIs on a 680x0 machine.
  15. All numbers in a .FLI file are in Intel format, so you may have to
  16. compensate for that, of course. - kevin
  17.  
  18. 8.1 Flic Files (.FLI)
  19.  
  20.      The details of a FLI file are moderately complex, but the
  21. idea behind it is simple: don't bother storing the parts of a
  22. frame that are the same as the last frame.  Not only does this
  23. save space, but it's very quick.  It's faster to leave a pixel
  24. alone than to set it.
  25.  
  26.      A FLI file has a 128-byte header followed by a sequence of
  27. frames. The first frame is compressed using a bytewise run-length
  28. compression scheme.  Subsequent frames are stored as the
  29. difference from the previous frame.  (Occasionally the first
  30. frame and/or subsequent frames are uncompressed.)  There is one
  31. extra frame at the end of a FLI which contains the difference
  32. between the last frame and the first frame.
  33.  
  34.      The FLI header:
  35.  
  36.      byte size name      meaning
  37.      offset
  38.  
  39.      0    4    size      Length of file, for programs that want
  40.                          to read the FLI all at once if possible.
  41.      4    2    magic     Set to hex AF11.  Please use another
  42.                          value here if you change format (even to
  43.                          a different resolution) so Autodesk
  44.                          Animator won't crash trying to read it.
  45.      6    2    frames    Number of frames in FLI.  FLI files have
  46.                          a maxium length of 4000 frames.
  47.      8    2    width     Screen width (320).
  48.      10   2    height    Screen height (200).
  49.      12
  50.      14   2    flags     Must be 0.
  51.      16   2    speed     Number of video ticks between frames.
  52.      18   4    next      Set to 0.
  53.      22   4    frit      Set to 0.
  54.      26   102  expand    All zeroes -- for future enhancement.
  55.  
  56.      Next are the frames, each of which has a header:
  57.  
  58.      byte size name      meaning
  59.      offset
  60.      0    4    size      Bytes in this frame.  Autodesk Animator
  61.                          demands that this be less than 64K.
  62.      4    2    magic     Always hexadecimal F1FA
  63.      6    2    chunks    Number of 'chunks' in frame.
  64.      8    8    expand    Space for future enhancements. All zeros.
  65.  
  66.      After the frame header come the chunks that make up the
  67. frame.  First comes a color chunk if the color map has changed
  68. from the last frame.  Then comes a pixel chunk if the pixels have
  69. changed.  If the frame is absolutely identical to the last frame
  70. there will be no chunks at all.
  71.  
  72.      A chunk itself has a header, followed by the data.  The
  73. chunk header is:
  74.  
  75.      byte size name meaning
  76.      offset
  77.      0    4    size Bytes in this chunk.
  78.      4    2    type Type of chunk (see below).
  79.  
  80.      There are currently five types of chunks you'll see in a FLI
  81. file:
  82.  
  83.      number    name      meaning
  84.      11        FLI_COLOR Compressed color map
  85.      12        FLI_LC    Line compressed -- the most common type
  86.                          of compression for any but the first
  87.                          frame.  Describes the pixel difference
  88.                          from the previous frame.
  89.      13        FLI_BLACK Set whole screen to color 0 (only occurs
  90.                          on the first frame).
  91.      15        FLI_BRUN  Bytewise run-length compression -- first
  92.                          frame only
  93.      16        FLI_COPY  Indicates uncompressed 64000 bytes soon
  94.                          to follow.  For those times when
  95.                          compression just doesn't work!
  96.  
  97.      The compression schemes are all byte-oriented.  If the
  98. compressed data ends up being an odd length a single pad byte is
  99. inserted so that the FLI_COPY's always start at an even address
  100. for faster DMA.
  101.  
  102. FLI_COLOR Chunks
  103.  
  104.      The first word is the number of packets in this chunk. This
  105. is followed directly by the packets.  The first byte of a packet
  106. says how many colors to skip.  The next byte says how many colors
  107. to change.  If this byte is zero it is interpreted to mean 256. 
  108. Next follows 3 bytes for each color to change (one each for red,
  109. green and blue).
  110.  
  111. FLI_LC Chunks
  112.  
  113.      This is the most common, and alas, most complex chunk.   The
  114. first word (16 bits) is the number of lines starting from the top
  115. of the screen that are the same as the previous frame. (For
  116. example, if there is motion only on the bottom line of screen
  117. you'd have a 199 here.)  The next word is the number of lines
  118. that do change.  Next there is the data for the changing lines
  119. themselves.  Each line is compressed individually; among other
  120. things this makes it much easier to play back the FLI at a
  121. reduced size.
  122.  
  123.      The first byte of a compressed line is the number of packets
  124. in this line.  If the line is unchanged from the last frame this 
  125. is zero.  The format of an individual packet is:
  126.  
  127.  skip_count
  128.  size_count
  129.  data
  130.  
  131.      The skip count is a single byte.  If more than 255 pixels
  132. are to be skipped it must be broken into 2 packets. The size
  133. count is also a byte.  If it is positive, that many bytes of data
  134. follow and are to be copied to the screen.  If it's negative a
  135. single byte follows, and is repeated -skip_count times.
  136.  
  137.      In the worst case a FLI_LC frame can be about 70K.  If it
  138. comes out to be 60000 bytes or more Autodesk Animator decides
  139. compression isn't worthwhile and saves the frame as FLI_COPY.
  140.  
  141. FLI_BLACK Chunks
  142.  
  143.      These are very simple.  There is no data associated with
  144. them at all. In fact they are only generated for the first frame
  145. in Autodesk Animator after the user selects NEW under the FLIC menu.
  146.  
  147. FLI_BRUN Chunks
  148.  
  149.      These are much like FLI_LC chunks without the skips.  They
  150. start immediately with the data for the first line, and go line-
  151. by-line from there.  The first byte contains the number of
  152. packets in that line.  The format for a packet is:
  153.  
  154.  size_count
  155.  data
  156.  
  157.      If size_count is positive the data consists of a single byte
  158. which is repeated size_count times. If size_count is negative
  159. there are -size_count bytes of data which are copied to the
  160. screen. In Autodesk Animator if the "compressed" data shows signs
  161. of exceeding 60000 bytes the frame is stored as FLI_COPY instead.
  162.  
  163. FLI_COPY Chunks
  164.  
  165.      These are 64000 bytes of data for direct reading onto the
  166. screen.
  167.  
  168.  -eof-
  169.  
  170. Notes: Since these are animations, the last frame will delta into a
  171. copy of the first one (which was usually a large BRUN chunk).  Therefore,
  172. looping should go back to the _second_ frame chunk (usually a LC
  173. or COLOR chunk) instead of all the way back to the file beginning, to
  174. avoid a "stutter" caused by unnecessarily redecoding the original frame.
  175. Also, a very few files may have palette animation, so write your code
  176. so that COLOR chunks can be found at any time.  - kevin
  177.